#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int main()
{

    string s;
    int numRows;
    cin >> s >> numRows;

    string ret;
    int n = s.size();
    ret.reserve(n);
    int k = 2 * numRows - 2;
    int count = 0;
    for (int i = 0; i < numRows; i++)
    {
        if (i == 0 || i == numRows - 1)
        {
            for (int j = i; j < n; j += k)
                //ret[count++] = s[j];
                ret.push_back(s[j]);
        }
        else
        {
            for (int j = i; j < n; j += k)
            {
                ret.push_back(s[j]);
                if (j + k - 2 * i < n) ret.push_back(s[j + k - 2 * i]) ;
            }
        }
    }
    cout << ret;
	return 0;
}